<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ajax异步交互</title>
</head>
<body>
<script src="js/jquery-2.2.3.min.js"></script>
<script>
    //ajax异步请求数据类型
      //单个数据
      //json类型数据
      //key=value类型
    $.ajax({
       type:'post',
       //url:'ajax/test?username=admin',
        url:'ajax/test1',
        //必须指定文档类型
        contentType:'application/json;charset=utf-8',
        data:'{"username":"admin","age":18}',
        //data:'username=admin&age=18',
        success:function (data) {
            alert("ok");
        },
        error:function () {
            alert("error");
        }
    });
</script>
</body>
</html>